#include "BFSBuildingPlacer.h"

#include "..\Util.h"

namespace BroodWar
{
	namespace Addon
	{
		BFSBuildingPlacer::BFSBuildingPlacer(BWSAL::BFSBuildingPlacer* placer)
		{
			instance = placer;
			dispose = false;
		}

		BFSBuildingPlacer::~BFSBuildingPlacer()
		{
			if(dispose)
				delete instance;
		}

		BFSBuildingPlacer::!BFSBuildingPlacer()
		{
			if(dispose)
				delete instance;
		}
		
		BFSBuildingPlacer::BFSBuildingPlacer()
		{
			instance = new BWSAL::BFSBuildingPlacer();
			dispose = true;
		}
		
		TilePosition^ BFSBuildingPlacer::FindBuildLocation(IReservedMap^ reserveMap, Api::Enum::UnitType unitType, TilePosition^ seedLocation, Unit^ builder)
		{
			return ConvertTile(instance->findBuildLocation(ConvertIReservedMap(reserveMap), ConvertUnitType(unitType), ConvertTile(seedLocation), ConvertUnit(builder)));
		}
		
		TilePosition^ BFSBuildingPlacer::FindBuildLocation(IReservedMap^ reserveMap, Api::Enum::UnitType unitType, TilePosition^ seedLocation)
		{
			return ConvertTile(instance->findBuildLocation(ConvertIReservedMap(reserveMap), ConvertUnitType(unitType), ConvertTile(seedLocation)));
		}
	}
}
